<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="stylesheet" type="text/css" href="/css/button-zxf.css"></link>
	<script type="text/javascript" src="/js/jquery.min.js"></script>
	<script type="text/javascript" src="/js/plug_zxf.js"></script>
</head>
<body>
	<%@include file="header.jsp" %>
		<div id="container">
		<div id="main" class="fullscreen">
			<div class="content fl person">
				<div class="section panel-box hijackthis hijacked">
					<div class="blog-article-box">
						<div style="margin-top:10px;">
							<font style="font-weight: bold;">淘宝授权:</font>
						</div>
						<div style="margin-top:10px; margin-left: 60px;">
							<font style="color: red;">
								<s:property value="errors['oauth'][0]" />
							</font>
						</div>
						<div style="margin-top:10px; margin-left: 60px;">	
							<div style="float: left;"><input type="text" name="nick" style="padding: 12px 0 14px 9px;height: 15px;font-size:18px;" disabled="disabled"></div>
							<div class="button-zxf" style="height:45px;margin-left:10px;width:80px;" onclick="doOauth()"><a href="#" style="line-height:45px; color: #FFFFFF;">授权</a></div>
							<img src="/images/taobao.png"><font size="2px;" style="color: #448EF3;">温习提示: 请点击 '授权', 只能绑定一个淘宝账号.</font>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		$(function(){
			taobao_oauth_uri = doAjaxUrl("/Taobao_oauth1");
			var uri = taobao_oauth_uri.split("&&");
			if(uri.length > 1){
				var nick = uri[uri.length-1];
				taobao_oauth_uri = taobao_oauth_uri.replace("&&" + nick, "");
				$("input[name = nick]").val(nick);
			}
		});
		
		function doOauth(){
			window.location.href = taobao_oauth_uri+"&state=system_setting.jsp";
		}
	/* 	function encode64(input) {
		      var output = "";
		      var chr1, chr2, chr3 = "";
		      var enc1, enc2, enc3, enc4 = "";
		      var i = 0;

		      do {
		                 chr1 = input.charCodeAt(i++);
		         chr2 = input.charCodeAt(i++);
		         chr3 = input.charCodeAt(i++);

		         enc1 = chr1 >> 2;
		         enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		         enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		         enc4 = chr3 & 63;

		         if (isNaN(chr2)) {
		            enc3 = enc4 = 64;
		         } else if (isNaN(chr3)) {
		            enc4 = 64;
		         }

		         output = output + 
		            keyStr.charAt(enc1) + 
		            keyStr.charAt(enc2) + 
		            keyStr.charAt(enc3) + 
		            keyStr.charAt(enc4);
		         chr1 = chr2 = chr3 = "";
		         enc1 = enc2 = enc3 = enc4 = "";
		      } while (i < input.length);

		      return output;
		   }

		  //将Base64编码字符串转换成Ansi编码的字符串
		   function decode64(input) {
		      var output = "";
		      var chr1, chr2, chr3 = "";
		      var enc1, enc2, enc3, enc4 = "";
		      var i = 0;
		          
		          if(input.length%4!=0)
		          {
		                    return "";
		          }
		      var base64test = /[^A-Za-z0-9\+\/\=]/g;
		          if (base64test.exec(input))
		          {
		                    return "";
		          }

		      do {
		         enc1 = keyStr.indexOf(input.charAt(i++));
		         enc2 = keyStr.indexOf(input.charAt(i++));
		         enc3 = keyStr.indexOf(input.charAt(i++));
		         enc4 = keyStr.indexOf(input.charAt(i++));

		         chr1 = (enc1 << 2) | (enc2 >> 4);
		         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		         chr3 = ((enc3 & 3) << 6) | enc4;
		                 
		                 output = output + String.fromCharCode(chr1);

		         if (enc3 != 64) {
		                        output+=String.fromCharCode(chr2);
		         }
		         if (enc4 != 64) {
		                        output+=String.fromCharCode(chr3);
		         }

		         chr1 = chr2 = chr3 = "";
		         enc1 = enc2 = enc3 = enc4 = "";

		      } while (i < input.length);

		      return output;
		   }
		   var de=encode64(strUnicode2Ansi("中国人"));
		   var en=strAnsi2Unicode(decode64(de));
		   document.writeln(de+"<br>");
		   document.writeln(en+"<br>"); */
	</script>
</body>
</html>